$(document).ready(function(){
    $('.time').change(function(){

        var startTime = new Date();

        if($('#TimesheetStartTimeMeridian').val() == "am")
            startTime.setHours($('#TimesheetStartTimeHour').val(), parseInt($('#TimesheetStartTimeMin').val()), 0, 0);
        else
            startTime.setHours(parseInt($('#TimesheetStartTimeHour').val()) + 12, parseInt($('#TimesheetStartTimeMin').val()), 0, 0);

        var endTime = new Date();

        if($('#TimesheetEndTimeMeridian').val() == "am")
            endTime.setHours($('#TimesheetEndTimeHour').val(), parseInt($('#TimesheetEndTimeMin').val()), 0 ,0);
        else
            endTime.setHours(parseInt($('#TimesheetEndTimeHour').val()) + 12, parseInt($('#TimesheetEndTimeMin').val()), 0 ,0);

        var totalHours = ((endTime - startTime) / (1000*3600)).toFixed(2);

        // alert(totalHours);

        $('#TimesheetTotalNoHrs').val(totalHours);
        
    });

}); 